package com.example.rbacmanage.service.system.impl;

import com.example.rbacmanage.entity.system.DictData;
import com.example.rbacmanage.mapper.system.DictDataMapper;
import com.example.rbacmanage.service.system.DictDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author xiezh
* @description 针对表【t_dict_data】的数据库操作Service实现
* @createDate 2025-03-26 21:27:06
*/
@Service
public class DictDataServiceImpl implements DictDataService{

    @Autowired
    private DictDataMapper dictDataMapper;
    @Override
    public void save(DictData dictData) {
        dictData.setCreateTime(new Date());
        dictData.setDelFlag("0");
        dictDataMapper.insert(dictData);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            dictDataMapper.del(id);
        }
    }

    @Override
    public void update(DictData dictData) {
        dictDataMapper.update(dictData);
    }

    @Override
    public List<DictData> getAll(DictData dictData) {
        return dictDataMapper.list(dictData);
    }

    @Override
    public PageInfo<DictData> getPage(DictData dictData) {
        PageHelper.startPage(dictData.getPage(),dictData.getLimit());
        return new PageInfo<>(getAll(dictData));
    }

    @Override
    public DictData getById(Long id) {
        return dictDataMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(DictData dictData) {
        return dictDataMapper.count(dictData);
    }
}
